<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>@pureadmin/table</title>

  <!-- jsdelivr cdn -->
  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/element-plus/dist/index.css" />
  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/element-plus/theme-chalk/dark/css-vars.css" />
  <script src="//cdn.jsdelivr.net/npm/vue/dist/vue.global.prod.js"></script>
  <script src="//cdn.jsdelivr.net/npm/element-plus/dist/index.full.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/@element-plus/icons-vue"></script>
  <script src="//cdn.jsdelivr.net/npm/@pureadmin/utils@latest"></script>
  <script src="//cdn.jsdelivr.net/npm/@pureadmin/table@latest"></script>
</head>

<body>

  <div id="app">
    <div style="display: flex;align-items: center;justify-content: space-around;width: 12em;">
      <h3>Html引入示例</h3>
      <el-switch v-model="isDark" inline-prompt size="large" :active-icon="Sunny" :inactive-icon="Moon"
        @change="toggleDark" />
    </div>
    <pure-table border :data="tableData" :columns="columns" :pagination="pagination"></pure-table>
  </div>

  <script>
    const { createApp, ref } = Vue
    const { toggleDark } = PureUtils.useDark()

    const app = Vue.createApp({
      data() {
        return {
          Moon: ElementPlusIconsVue.Moon,
          Sunny: ElementPlusIconsVue.Sunny,
          isDark: false,
          columns: [
            {
              label: "Date",
              prop: "date",
            }, {
              label: "Name",
              prop: "name",
            }, {
              label: "Address",
              prop: "address",
            }
          ],
          tableData: [
            {
              date: '2030-05-01',
              name: 'Tom',
              address: 'No. 189, Grove St, Los Angeles',
            },
            {
              date: '2030-05-02',
              name: 'Tom',
              address: 'No. 189, Grove St, Los Angeles',
            },
            {
              date: '2030-05-03',
              name: 'Tom',
              address: 'No. 189, Grove St, Los Angeles',
            },
            {
              date: '2030-05-04',
              name: 'Tom',
              address: 'No. 189, Grove St, Los Angeles',
            },
          ],
          pagination: {
            pageSize: 5,
            currentPage: 1,
            background: true,
            total: 0
          }
        }
      },
      mounted() {
        this.pagination.total = this.tableData.length
      },
      methods: {
        toggleDark
      },
    })

    app.use(ElementPlus).use(PureTable.default, { locale: "zhCn" }).mount("#app")
  </script>

</body>

</html>